package com.huyun.web.FutureTest;

import java.util.concurrent.CompletableFuture;

/**
 * @program:
 * @description:
 * @author: hyq
 * @create: 2021-12-30 14:45
 */
public class WhenCompleteTest {
    public static void main(String[] args) {
        /**
         * whenComplete计算结果的处理：
         * 对前面计算结果进行处理，无法返回新值
         */
        CompletableFuture<String> cf1 = CompletableFuture.supplyAsync(() -> "hello");
        CompletableFuture<String> cf2 = cf1.whenComplete((v, e) ->
                System.out.println(String.format("value:%s, exception:%s", v, e)));
        System.out.println(cf2.join());
    }
}
